<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>登录界面</title>
  <link rel="stylesheet" href="./css/style.css">
  <link rel="stylesheet" href="./css/body.css">
  
</head>
<body>
  <div class="container">
    <section id="content">
      <form>
        <h1>账号登录</h1></h1>
        <div>
          <i class="close">X</i>
          <input type="text" placeholder="手机号" id="username" name="username">
        </div>
        <div>
          <i class="close">X</i>
          <input type="password" placeholder="密码" id="password" name="password">
        </div>
        <div>
          <input type="submit" value="登录" class="btn btn-primary" id="js-btn-login">
          <a href="">忘记密码?</a>
          <a href="#">注册账号</a>
        </div>
      </form>
    </section>
  </div>
  <script src="/jquery.min.js"></script>
  <script src="/axios.js"></script>
  <script src="/dizhi.js"></script>
  <script>
$(function (){
 
  $('#js-btn-login').on('click',async function(e){
    e.preventDefault()
    const {data:{data}}= await axios({
      url:'/user/login',
      method:'POST',
      data:{
        username:$('#username').val(),
        password:$('#password').val()
      }
    })
    localStorage.setItem('token', data.token)
  })

  
  // console.log($('#username').val());
  // $('#js-btn-login').on('click',function(e){
  //   e.preventDefault()
  //   $.ajax({
  //   url:'/user/login',
  //   method:'POST',
  //   data:{
  //     username:$('#username').val(),
  //     password:$('#password').val()
  //   },
  //   success:function(res){
  //     // if(res.status!==200){
  //     //   return alert(res.msg)
  //     // }
  //     console.log(res);
  //     localStorage.setItem('token', res.data.token)
  //     console.log(res.data.token);
  //       //  location.href = '/05-cartBaseCode/index.html'
  //   }
  // })
  // })
  
})
  </script>
</body>
</html>